home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FishMarket 1.0
/
FishMarket v1.0.iso
/
fishies
/
301-325
/
disk_313
/
uucp
/
uucp1.lzh
/
src
/
lib
/
seq.c
< prev
next >
Wrap
C/C++ Source or Header
|
1990-01-14
|
643b
|
44 lines
/*
* SEQ.C
*
* (C) Copyright 1989-1990 by Matthew Dillon, All Rights Reserved.
*
* Returns a unique sequence number
*/
#include <stdio.h>
GetSequence(bump)
{
char *seqfile = "UULIB:seq";
FILE *fp;
int seq;
char buf[32];
LockFile(seqfile);
fp = fopen("UULIB:seq","r");
if (fp) {
fgets(buf, 32, fp);
seq = atoi(buf);
fclose(fp);
} else {
perror("UULIB:seq");
seq = -1;
}
if (seq > 0) {
fp = fopen("UULIB:seq", "w");
if (fp) {
fprintf(fp,"%d", seq + bump);
fclose(fp);
} else {
perror("UULIB:seq");
seq = -1;
}
}
UnLockFile(seqfile);
return(seq);
}